let http=require('http')
let server=http.createServer()
let fs=require('fs')

server.on('request',(req,res)=>{
	if(req.url=="/index"){
		fs.readFile("./index.html","utf-8",(err,data)=>{
			res.setHeader('Content-Type',"text/plain;charset=utf-8")
			res.end(data)
		})
	}else if(req.url=='/login'){
		res.write("这是登录页")
		res.end('this is login page')
	}else if(req.url=='/register'){
		res.write("这是注册页")
		res.end('this is register page')
	}else{
		res.write("没有这页")
		res.end('no this page')
	}
})

server.listen(2000,function(){
	console.log('服务器成功启动，请在浏览器中输入：http://127.0.0.1:2000执行')
})